﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

using VideoPlay.PhoneClient.ViewModels;
using System.Windows.Media;
using Microsoft.Phone.Tasks;
using Coding4Fun.Toolkit.Controls;

namespace VideoPlay.PhoneClient.Views
{
    public partial class VideoListView : PhoneApplicationPage
    {
        public VideoListView()
        {
            InitializeComponent();
            //this.spinner.IsSpinning = true;
        }

        private void Image_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            Image image = sender as Image;
            VideoViewModel video = image.DataContext as VideoViewModel;
            video.LikeUnlike();
        }

        private void TextBlock_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            TextBlock textblock = sender as TextBlock;
            VideoViewModel video = textblock.DataContext as VideoViewModel;
            video.Play();
        }

        private void VideoImage_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            Image image = sender as Image;
            VideoViewModel video = image.DataContext as VideoViewModel;
            video.Play();
        }

        //search
        private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)
        {
            ((VideoListViewModel)this.DataContext).SearchVideo();
        }

        //refresh
        private void ApplicationBarIconButton_Click_2(object sender, EventArgs e)
        {
            var selectedCategory = ((VideoListViewModel)this.DataContext).SelectedCategory;
            if (selectedCategory != null)
            {
                selectedCategory.LoadCategoryContent();
            }
        }

        private void Grid_Tap_1(object sender, System.Windows.Input.GestureEventArgs e)
        {
            Grid grid = sender as Grid;
        }

        private void ApplicationBarIconButton_Click_3(object sender, EventArgs e)
        {
            MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
            marketplaceReviewTask.Show();
        }

    }
}